﻿@page "/HYJ_MasterDetail_Table_CRUD"
@using BBCore.Core.Models.Samples
@using BBCore.Server.PublicComponentBase
@using BBCore.Core.Models.EnumTypes
@inherits Master_Detail_ComponentBase
@inject IDataQueryService<HYJ_Master_Table> IMasterDataQueryService
@inject IDataQueryService<HYJ_Detail_Table> IDetailDataQueryService
<Table TItem="HYJ_Master_Table" 
       IsBordered="true" IsStriped="true" IsPagination="true" PageItemsSource="new int[] { 5,10,20}"
       ShowEmpty="true" EmptyText="暂无数据" EmptyImage="images/empty.svg" ClickToSelect="true"
       ShowSkeleton="true" ShowLoading="true" ShowSearch="true" ShowRefresh="false"
       ShowAddButton="@AuthorizeButton(ButtonPermissionTypeEnum.Add)"
       ShowEditButton="@AuthorizeButton(ButtonPermissionTypeEnum.Edit)"
       ShowDeleteButton="@AuthorizeButton(ButtonPermissionTypeEnum.Del)"
       ShowExtendEditButton="false"
       ShowExtendDeleteButton="false"
       OnQueryAsync="@OnMasterQueryAsync" OnDeleteAsync="@OnMasterDeleteAsync" OnSaveAsync="@OnMasterSaveAsync"
       ShowToolbar="true"
       ShowExportButton="true">
        <TableToolbarTemplate>
        <TableToolbarButton Color="Color.Primary" Text="模板下载" Icon="fas fa-download" IsShow="@AuthorizeButton(ButtonPermissionTypeEnum.Template)" OnClick="tempDownload"></TableToolbarButton>
        </TableToolbarTemplate>
    <TableColumns>
        <TableColumn @bind-Field="@context.JOB_NO" Searchable="true"></TableColumn>
        <TableColumn @bind-Field="@context.QUANTITY"></TableColumn>
        <TableColumn @bind-Field="@context.REQ_DATE"></TableColumn>
    </TableColumns>
    <DetailRowTemplate Context="master">
        <Table TItem="HYJ_Detail_Table" @ref="_Detail" Style="background-color:antiquewhite;"
               IsStriped="true" IsBordered="true" IsMultipleSelect="true" IsPagination="true" PageItemsSource="new int[] { 5,10,20}"
               EditDialogIsDraggable="true" ShowToolbar="true" ShowRefresh="false" EmptyText="暂无数据" EmptyImage="images/empty.svg"
               ShowSkeleton="true" ShowSearch="true" ShowExportButton="true"
               ShowAddButton="@AuthorizeButton(ButtonPermissionTypeEnum.Add)"
               ShowEditButton="false"
               ShowDeleteButton="@AuthorizeButton(ButtonPermissionTypeEnum.Del)"
               ShowExtendEditButton="@AuthorizeButton(ButtonPermissionTypeEnum.Edit)"
               ShowExtendDeleteButton="@AuthorizeButton(ButtonPermissionTypeEnum.Del)"
               ShowExtendButtons="true"
               OnQueryAsync="@(async options => await OnDetailQueryAsync(options, master))"
               OnDeleteAsync="@(async items => await OnDetailDeleteAsync(items))"
               OnSaveAsync="@(async (item, changedType) => await OnDetailSaveAsync(item, changedType, master))">
               <TableToolbarTemplate>
                @if (AuthorizeButton(ButtonPermissionTypeEnum.Import))
                {
                    <TableToolbarComponent TItem="HYJ_Detail_Table">
                        <ButtonUpload TValue="string" ShowUploadFileList="false" BrowserButtonClass="btn-secondary"
                                      Accept=".xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                                      BrowserButtonText="导入" OnChange="@(async uploadFile => await DataImport(uploadFile, master))"></ButtonUpload>
                    </TableToolbarComponent>
                }
               </TableToolbarTemplate>
            <TableColumns>
                <TableColumn @bind-Field="@context.ITEM" Searchable="true"></TableColumn>
                <TableColumn @bind-Field="@context.LEVEL2"></TableColumn>
            </TableColumns>
        </Table>
    </DetailRowTemplate>
</Table>


